
def median_func(data_list):
    data_sorted = sorted(data_list, reverse = False)
    data_num = len(data_sorted)
    if data_num % 2:
        return data_sorted[(data_num+1)/2]
    return .5*(data_sorted[int(data_num/2-1)]+data_sorted[int(data_num/2)])

if __name__ == '__main__':
    import numpy as np
    data_list = [1,2,3,4]
    print(median_func(data_list))
    print(np.median(data_list))
